#!/usr/bin/env python3
import time
import os

text = input('please input something:')

try:
    f = open('aa.txt', 'w')
    f.write(text + '\n')
except Exception as e:
    t = time.ctime()
    user = os.getlogin()
    f_log = open('aa_log.txt', 'w')
    f_log.write('{0} {1} {2}\n'.format(e, t, user))
    f_log.close()
    print('write fail. check log file for detail')
finally:
    if 'f' in locals():
        f.close()
